package com.zyf.chapter01.principle.LOD.refactor;

import com.zyf.chapter01.principle.LOD.utils.Html;
import com.zyf.chapter01.principle.LOD.utils.HtmlRequest;

/**
 * 通过URL获取网页
 * @author yifeng
 */
public class HtmlDownloader {
    private NetworkTransporter transporter;// 通过构造函数或IOC注入

    // HtmlDownloader 这里也要有相应的修改
    public Html downloadHtml(String url) {
        HtmlRequest htmlRequest = new HtmlRequest(url);
        Byte[] rawHtml = transporter.send(htmlRequest.getAddress(), htmlRequest.getContent().getBytes());
        return new Html(rawHtml);
    }
}